package com.ruowei.modules.wxpay.domain;

import com.ruowei.modules.wxpay.domain.enumeration.PayReturnType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.io.Serializable;
import java.time.Instant;
import java.time.LocalDate;

/**
 * 微信支付返回数据表
 */
@ApiModel(description = "微信支付返回数据表")
@Entity
@Table(name = "we_chat_pay_return")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class WeChatPayReturn implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 订单号
     */
    @ApiModelProperty(value = "订单号")
    @Column(name = "order_code")
    private String orderCode;

    /**
     * 退款编码
     */
    @ApiModelProperty(value = "退款编码")
    @Column(name = "order_rerun_code")
    private String orderRerunCode;

    /**
     * 时间
     */
    @ApiModelProperty(value = "时间")
    @Column(name = "jhi_time")
    private Instant time;

    /**
     * 返回数据json
     */
    @ApiModelProperty(value = "返回数据json")
    @Lob
    @Column(name = "json_data")
    private String jsonData;

    /**
     * 返回数据类型
     */
    @ApiModelProperty(value = "返回数据类型")
    @Enumerated(EnumType.STRING)
    @Column(name = "jhi_type")
    private PayReturnType type;

    /**
     * 日期
     */
    @ApiModelProperty(value = "日期")
    @Column(name = "jhi_date")
    private LocalDate date;

    // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getOrderCode() {
        return orderCode;
    }

    public WeChatPayReturn orderCode(String orderCode) {
        this.orderCode = orderCode;
        return this;
    }

    public void setOrderCode(String orderCode) {
        this.orderCode = orderCode;
    }

    public String getOrderRerunCode() {
        return orderRerunCode;
    }

    public WeChatPayReturn orderRerunCode(String orderRerunCode) {
        this.orderRerunCode = orderRerunCode;
        return this;
    }

    public void setOrderRerunCode(String orderRerunCode) {
        this.orderRerunCode = orderRerunCode;
    }

    public Instant getTime() {
        return time;
    }

    public WeChatPayReturn time(Instant time) {
        this.time = time;
        return this;
    }

    public void setTime(Instant time) {
        this.time = time;
    }

    public String getJsonData() {
        return jsonData;
    }

    public WeChatPayReturn jsonData(String jsonData) {
        this.jsonData = jsonData;
        return this;
    }

    public void setJsonData(String jsonData) {
        this.jsonData = jsonData;
    }

    public PayReturnType getType() {
        return type;
    }

    public WeChatPayReturn type(PayReturnType type) {
        this.type = type;
        return this;
    }

    public void setType(PayReturnType type) {
        this.type = type;
    }

    public LocalDate getDate() {
        return date;
    }

    public WeChatPayReturn date(LocalDate date) {
        this.date = date;
        return this;
    }

    public void setDate(LocalDate date) {
        this.date = date;
    }
    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof WeChatPayReturn)) {
            return false;
        }
        return id != null && id.equals(((WeChatPayReturn) o).id);
    }

    @Override
    public int hashCode() {
        return 31;
    }

    @Override
    public String toString() {
        return "WeChatPayReturn{" +
            "id=" + getId() +
            ", orderCode='" + getOrderCode() + "'" +
            ", orderRerunCode='" + getOrderRerunCode() + "'" +
            ", time='" + getTime() + "'" +
            ", jsonData='" + getJsonData() + "'" +
            ", type='" + getType() + "'" +
            ", date='" + getDate() + "'" +
            "}";
    }
}
